SESSION 11 - Project on Object Detection - Part I

TOC
PART I

  1. Setup
  2. Install
  3. Imports
  4. Model preparation
    4.1 Loader
    4.2 Loading label map

Real-time object detection and tracking is a vast, vibrant yet inconclusive and complex area of computer vision. Due to its increased utilization in surveillance, tracking system used in security and many others applications have propelled researchers to continuously devise more efficient and competitive algorithms. The latest research on this area has been making great progress in many directions. In the current manuscript, we give an overview of the necessity of object detection in today’s computing systems, outline the current main research directions, discuss on how our API algorithm works, and discuss open problems and possible future directions. Key words: - Object Detection, Computer Vision, Tracking Systems, API algorithm.

1. Setup

Packages to be installed:

  1. pip install protobuf
  2. pip install pillow
  3. pip install lxml
  4. pip install Cython
  5. pip install jupyter
  6. pip install matplotlib
  7. pip install pandas
  8. pip install opencv-python 
  9. pip install tensorflow

2. Install

pip install -U --pre tensorflow=="2.*"

Make sure you have pycocotools installed

pip install pycocotools

Python Implementation

Get tensorflow/models or cd to parent directory of the repository.

Compile protobufs and install the object_detection package

3. Imports

Import the object detection module.

Patches:

4. Model preparation

Variables

Any model exported using the export_inference_graph.py tool can be loaded here simply by changing the path.

By default we use an "SSD with Mobilenet" model here. See the detection model zoo for a list of other models that can be run out-of-the-box with varying speeds and accuracies.

4.1 Loader

4.2 Loading label map

Label maps map indices to category names, so that when our convolution network predicts 5, we know that this corresponds to airplane. Here we use internal utility functions, but anything that returns a dictionary mapping integers to appropriate string labels would be fine

For the sake of simplicity we will test on 2 images:

5. Detection

5.1 Load an object detection model:

5.2 Check the model's input signature, it expects a batch of 3-color images of type uint8:

And retuns several outputs:

5.3 Add a wrapper function to call the model, and cleanup the outputs:

5.4 Run it on each test image and show the results:

6. Instance Segmentation

The instance segmentation model includes a detection_masks output: